package com.itheima.web.controller;

import com.itheima.domain.Employee;
import com.itheima.domain.ResultInfo;
import com.itheima.service.EmployeeService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/employee")
public class EmployeeController {

    private EmployeeService employeeService;

    public EmployeeController(EmployeeService employeeService) {
        this.employeeService = employeeService;
    }

    @GetMapping
    public ResultInfo findEmployeeList(){
        List<Employee> employees = employeeService.findEmployeeList();
        return new ResultInfo(true, "查询", employees);
    }

    @PostMapping
    public ResultInfo save(@RequestBody Employee employee){
        employeeService.save(employee);
        return new ResultInfo(true, "添加成功", null);
    }
}
